/**
* @author: 善良的YWJ
* @Created by shanliangdeYWJ on 2020/09/16 02:09:18
* @file: index.js
* @description:
* ==================
* router 路由文件
* ==================
* @link [Github](https://github.com/shanliangdeYWJ)
 */
// 关于我们
import About from '@/views/about/about.vue';
import Concept from '@/views/about/concept.vue';
import History from '@/views/about/history.vue';
import Introduce from '@/views/about/introduce.vue';
import Management from '@/views/about/management.vue';
// 主页，放置导航菜单，路由视图插槽
import Home from '@/views/home.vue';
// 首页内容
import Index from '@/views/index/index.vue';
import JoinUs from '@/views/join/join-us.vue';
// 加入我们
import Join from '@/views/join/join.vue';
import CompanyInfo from '@/views/news/company-info.vue';
// 最新消息
import News from '@/views/news/news.vue';
import Quotation from '@/views/news/quotation.vue';
import Building from '@/views/product/building.vue';
import Pipeline from '@/views/product/pipeline.vue';
import Plumbing from '@/views/product/plumbing.vue';
// 产品中心
import Product from '@/views/product/product.vue';
import ContactUs from '@/views/service/contact-us.vue';
import ProductIntro from '@/views/service/product-intro.vue';
// 服务中心
import Service from '@/views/service/service.vue';
import Transport from '@/views/service/transport.vue';
// 会员中心
import Vip from '@/views/vip/vip.vue';
import Vue from 'vue';
import VueRouter from 'vue-router';

Vue.use(VueRouter);

const routes = [
  // 访问根路径跳转到 Home
  { path: '/', name: 'Home', component: Home, redirect: '/Home' },
  // 访问Home 跳转到Index  Home这个组件存放 nav 导航
  {
    path: '/Home',
    name: 'Home',
    component: Home,
    redirect: '/Index',
    children: [
      // 首页
      { path: '/Index', component: Index },
      // 关于我们
      {
        path: '/About',
        name: 'About',
        component: About,
        redirect: '/About/Introduce',
        children: [
          { path: 'Introduce', name: 'Introduce', component: Introduce },
          { path: 'History', name: 'History', component: History },
          { path: 'Concept', name: 'Concept', component: Concept },
          { path: 'Management', name: 'Management', component: Management }
        ]
      },
      {
        path: '/Product',
        name: 'Product',
        component: Product,
        redirect: '/Product/Pipeline',
        children: [
          { path: 'Pipeline', name: 'Pipeline', component: Pipeline },
          { path: 'Plumbing', name: 'Plumbing', component: Plumbing },
          { path: 'Building', name: 'Building', component: Building }
        ]
      },
      {
        path: '/Service',
        name: 'Service',
        component: Service,
        redirect: '/Service/Transport',
        children: [
          { path: 'Transport', name: 'Transport', component: Transport },
          { path: 'ProductIntro', name: 'ProductIntro', component: ProductIntro },
          { path: 'ContactUs', name: 'ContactUs', component: ContactUs }
        ]
      },
      {
        path: '/News',
        name: 'News',
        component: News,
        redirect: '/News/Quotation',
        children: [
          { path: 'Quotation', name: 'Quotation', component: Quotation },
          { path: 'CompanyInfo', name: 'CompanyInfo', component: CompanyInfo }
        ]
      },
      {
        path: '/Join',
        name: 'Join',
        component: Join,
        redirect: '/Join/JoinUs',
        children: [
          { path: 'JoinUs', name: 'JoinUs', component: JoinUs }
        ]
      },
      {
        path: '/Vip',
        name: 'Vip',
        component: Vip
      },
      // 最外层路由设置的 * 匹配所有错误的路由，转发到这层 因为这层可以显示 nav导航 而 404 可以显示错误
      { path: 'Error', component: { template: '<h1>404 not found</h1>' } }
    ]
  },
  // 这里写在外面，本来只返回 404信息，
  // 但是由于只能返回404 显得不友好少了导航页面，
  // 重新开一个404组件浪费，所以 重定向到 home
  { path: '*', redirect: '/Home/Error' }
];

const router = new VueRouter({
  mode: 'history',
  routes
});

export default router;
